<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no,viewport-fit=cover">
		<title>修改昵称</title>
		<link rel="stylesheet" href="../../../css/mui.min.css">
		<link rel="stylesheet" href="../../../css/app.css">
		<style>
			body{background: #fff;}
			input{border-radius:0!important;}
			.oldPet{width: 100%;height: 0.3rem;position: absolute;top: 1.09rem;left: 0;text-align: center;font-size: 0.28rem;color: #aeaeae;}
			.oldPet span b{color: #333333;}
			.newPet{width: 100%;height: 0.79rem !important;border:0.01rem solid #e2e2e2 !important;border-left: none !important;border-right: none !important;outline: none;position: absolute;top: 2.36rem;left: 0;margin: 0 !important;font-size: 0.26rem;}
			input::-webkit-input-placeholder {font-size:0.26rem;color: #cfcfcf;} 
			.save{width: 6rem;height: 0.68rem;background: #117afd;font-size: 0.3rem;color: #fff;border: none;outline: none;position: absolute !important;top: 4.2rem  !important;left: 0.75rem !important;border-radius: 0.1rem;}
															
		</style>
	</head>
	<body>
		<!--<div class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<a class="back">返回</a>
			<h1 class="mui-title">修改昵称</h1>
		</div>-->
		<div class="oldPet"><span>您当前昵称：<b id="nickName">guomm</b></span></div>
		<input type="text" class="newPet" placeholder="请输入昵称"/>
		<button class="save">保存</button>
	</body>
	<script src="../../../js/mui.min.js"></script>
	<script src="../../../js/common.js"></script>
	<script src="../../../js/app.js"></script>
	<script>
		mui.plusReady(function(){
			var nickName = localStorage.getItem('nickName');
			document.getElementById('nickName').innerHTML = nickName;
			/*mui.back = function(){
				plus.webview.currentWebview().close('zoom-fade-in',100);
			}*/
		});
		document.querySelector('.save').addEventListener('tap',function(){
			var newPet = document.querySelector('.newPet').value.trim();
			if (newPet == '' || newPet == undefined) {
				mui.toast('昵称不能为空');
			} else {
				var param = {};
				param.nickName = newPet;
				param.userId = getUserId();
				utils.ajax('appUserInfo/nickName.do',function(data){
					var data = JSON.parse(data);
					if (data.state == '1') {
						mui.toast('修改成功！');
						var opener = plus.webview.currentWebview().opener();
		        		mui.fire(opener, 'refresh');
						mui.back();
					} else {
						mui.toast(data.msg);
					}
				},jsonToParams(param),null, function(){
					mui.toast('抱歉，当前服务不可用，请稍后再试');
				});
			}
		});
	</script>
</html>